package com.power.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.power.domain.Member;
import com.power.mapper.MemberMapper;
import com.power.service.MemberService;
import com.power.util.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author dingchunlin
 * @description 针对表【member(用户表)】的数据库操作Service实现
 * @createDate 2024-07-10 15:12:13
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

    @Autowired
    private MemberMapper memberMapper;


    /**
     * 根据openId修改用户信息
     *
     * @param member
     * @return
     */
    @Override
    public Boolean modifyMemberInfoByOpenId(Member member) {
        String memberOpenId = AuthUtils.getMemberOpenId();
        member.setUpdateTime(new Date());
        // 更新会员头像和昵称
        return memberMapper.update(member, new LambdaQueryWrapper<Member>()
                .eq(Member::getOpenId, memberOpenId)) > 0;
    }
}




